﻿using PlatForm.Presentation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PlatForm
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void mnuSupplier_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(frmSupplier))
                {
                    form.Activate();
                    return;
                }
            }

            var frmSupplier = new frmSupplier { MdiParent = this };
            frmSupplier.Show();
        }

        private void mnuPackage_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(frmPackage))
                {
                    form.Activate();
                    return;
                }
            }

            var frmPackage = new frmPackage {MdiParent = this};
            frmPackage.Show();
        }

        private void mnuArticle_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(frmArticle))
                {
                    form.Activate();
                    return;
                }
            }

            var frmArticle = new frmArticle {MdiParent = this};
            frmArticle.Show();
        }

        private void mnuStore_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(frmStore))
                {
                    form.Activate();
                    return;
                }
            }

            var frmStore = new frmStore {MdiParent = this};
            frmStore.Show();
        }
        
        private void mnuPicking_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof (frmPick))
                {
                    form.Activate();
                    return;
                }
            }

            var frm = new frmPick {MdiParent = this};
                frm.Show();
        }

        private void buttonExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void mnuStock_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(frmStock))
                {
                    form.Activate();
                    return;
                }
            }

            var frm = new frmStock { MdiParent = this };
            frm.Show();
        }

        private void mnuStockReport_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(frmStockReport))
                {
                    form.Activate();
                    return;
                }
            }

            var frm = new frmStockReport { MdiParent = this };
            frm.Show();
        }

        private void mnuLackReport_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(frmLackReport))
                {
                    form.Activate();
                    return;
                }
            }

            var frm = new frmLackReport { MdiParent = this };
            frm.Show();
        }

       private void mnuKPIReport_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(frmKPIReport))
                {
                    form.Activate();
                    return;
                }
            }

            var frm = new frmKPIReport { MdiParent = this };
            frm.Show();
        }

       private void mnuImport_Click(object sender, EventArgs e)
       {
           foreach (Form form in Application.OpenForms)
           {
               if (form.GetType() == typeof(frmOrderImport))
               {
                   form.Activate();
                   return;
               }
           }

           var frm = new frmOrderImport { MdiParent = this };
           frm.Show();
       }

       private void mnuQC_Click(object sender, EventArgs e)
       {
           foreach (Form form in Application.OpenForms)
           {
               if (form.GetType() == typeof(frmQC))
               {
                   form.Activate();
                   return;
               }
           }

           var frm = new frmQC { MdiParent = this };
           frm.Show();
       }

    }
}
